﻿using System;
using TechTalk.SpecFlow;
using FluentAssertions;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DocProcessingWorkFlowScenarios
{
    [Binding]
    public class BBOSMyDetailsSteps
    {

        private string username { get; set; }
        [Given]
        public void Given_Username_of_USERNAME_displayed(string username)
        {
            this.username = username.ToLower();

            Assert.IsTrue(BrowserUtility.Current.PageSource.ToLower().Contains(this.username));
            //BrowserUtility.Current.FindElement(By.LinkText(username.ToLower())).Click();
        }

        [When]
        public void When_I_click_username()
        {
            // BrowserUtility.Current.FindElements(By.TagName("a"))[1].Click();
            var usernameLink = BrowserUtility.Current.FindElements(By.TagName("a")).ToList().Find(e => e.Text.ToLower().Contains(this.username));
            usernameLink.Click();
        }

        [Then]
        public void Then_the_My_Details_page_displayed()
        {
            BrowserUtility.Current.Url.Contains("http://dev.nexdox.com/DocProcessingWorkflow/User/Edit/pritpal");
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("MY DETAILS"), "MY DETAILS text not present");
            //BrowserUtility.Current.Close();
            //BrowserUtility.Current.Dispose();

        }
    }
}
